﻿#region Using Statements
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
#endregion

namespace TheSpirit
{
    class Map000 : Map
    {
        #region Initialize

        public Map000()
        {
            worldLocation.X = 0;
            worldLocation.Y = 0;
        }

        public override void LoadContent(ContentManager content)
        {
            backgroundTexture = content.Load<Texture2D>("Background/back000");
        }

        #endregion


        #region Draw

        public override void Draw(SpriteBatch spriteBatch)
        {
            int dx = Constants.SCREENX;
            int dy = Constants.SCREENY;
            int dw = Constants.SCREENWIDTH;
            int dh = Constants.SCREENHEIGHT;

            int sx = worldLocation.X;
            int sy = worldLocation.Y;
            int sw = Constants.SCREENWIDTH;
            int sh = Constants.SCREENHEIGHT;

            spriteBatch.Draw(backgroundTexture, new Rectangle(dx, dy, dw, dh), new Rectangle(sx, sy, sw, sh), Color.White, 0f, Vector2.Zero, SpriteEffects.None, 0f);

            foreach (Enemy e in openEnemy)
            {
                e.Draw(spriteBatch);
            }
        }

        #endregion


        #region Helper

        public override void SetTile(Tile[,] tile, ContentManager content)
        {
            for (int i = 0; i < 4; i++ )
                tile[i, 4].tileState = Tile.TileState.Road;
            for (int i = 4; i < 12; i++ )
                tile[3, i].tileState = Tile.TileState.Road;
            for (int i = 3; i < 7; i++ )
                tile[i, 11].tileState = Tile.TileState.Road;
            for (int i = 11; i < 17; i++ )
                tile[6, i].tileState = Tile.TileState.Road;
            for (int i = 6; i < 13; i++ )
                tile[i, 16].tileState = Tile.TileState.Road;
            for (int i = 8; i < 17; i++ )
                tile[12, i].tileState = Tile.TileState.Road;
            tile[13, 8].tileState = Tile.TileState.Road;

            for (int i = 0; i < 2; i++)
                for (int j = 0; j < 14; j++ )
                    tile[j, i].tileState = Tile.TileState.Block;
            for (int i = 6; i < 11; i++)
                for (int j = 3; j < 10; j++ )
                    tile[i, j].tileState = Tile.TileState.Block;
            for (int i = 11; i < 14; i++)
                for (int j = 3; j < 5; j++ )
                    tile[i, j].tileState = Tile.TileState.Block;
            tile[11, 5].tileState = Tile.TileState.Block;
            for (int i = 7; i < 11; i++)
                for (int j = 10; j < 12; j++ )
                    tile[i, j].tileState = Tile.TileState.Block;
            for (int i = 12; i < 20; i++ )
                tile[2, i].tileState = Tile.TileState.Block;
            for (int i = 13; i < 20; i++ )
                tile[3, i].tileState = Tile.TileState.Block;


            tile[1, 6].tileState = Tile.TileState.Block;
            tile[7, 12].tileState = Tile.TileState.Block;
            tile[8, 12].tileState = Tile.TileState.Block;
            tile[12, 19].tileState = Tile.TileState.Block;
            tile[13, 19].tileState = Tile.TileState.Block;
            tile[13, 18].tileState = Tile.TileState.Block;

            for (int i = 0; i < 2; i++)
                for (int j = 7; j < 20; j++ )
                    tile[i, j].tileState = Tile.TileState.Block;
            for (int i = 4; i < 14; i++)
                tile[i, 2].tileState = Tile.TileState.Block;


            SetEnemy(tile, content);
        }

        public override void SetEnemy(Tile[,] tile, ContentManager content)
        {
            closeEnemy.Add(new EnemyForest1(0, 4));
            closeEnemy.Add(new EnemyForest1(0, 4));
            closeEnemy.Add(new EnemyForest1(0, 4));
            closeEnemy.Add(new EnemyForest1(0, 4));
            closeEnemy.Add(new EnemyForest1(0, 4));

            foreach (Enemy e in closeEnemy)
            {
                e.LoadContent(content);
                e.SetTile(tile);
            }
        }

        #endregion
    }
}
